package com.mobile.ado.setting.ringtone;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ListView;

import com.mobile.ado.R;

public class RingtoneSettingTimerActivity extends Activity {

	private Activity activity;

	private ImageButton addScheduleButton;
	private ListView scheduleListView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		activity = this;
		setContentView(R.layout.ringtone_timer);

		setupAddScheduleButton();

		setupScheduleListView();

	}

	private void setupScheduleListView() {
		scheduleListView = (ListView) findViewById(R.id.scheduleListView);
		ArrayList<TimeSpanRingtone> ringtones = getRingtones();
		RingtoneSettingTimerAdapter adapter = new RingtoneSettingTimerAdapter(
				this, ringtones);
		scheduleListView.setAdapter(adapter);
	}

	private ArrayList<TimeSpanRingtone> getRingtones() {
		ArrayList<TimeSpanRingtone> ringtones = new ArrayList<TimeSpanRingtone>();
		// Calendar startTime = Calendar.getInstance();
		// Calendar endTime = Calendar.getInstance();
		// String audioPath = "AAAAAAAAAAAAAA";
		// TimeSpanRingtone ringtone = new TimeSpanRingtone(startTime, endTime,
		// audioPath);

		SharedPreferences preferences = getSharedPreferences("ringtones",
				Context.MODE_PRIVATE);
		Map<String, String> maps = (Map<String, String>) preferences.getAll();

//		ringtones.add(ringtone);
		return ringtones;
	}

	private void setupAddScheduleButton() {
		addScheduleButton = (ImageButton) findViewById(R.id.addSchedule);
		addScheduleButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View paramView) {
				RingtoneSettingAddTimerDialog dialog = new RingtoneSettingAddTimerDialog(
						activity, R.style.MyDialog);
				dialog.show();
			}
		});
	}
}
